<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			.box{
				display: flex;
				height: 100vh;
			}
			.left{
				background-color: lightgrey;
				width: 200px;
				height: 100%;
				text-align: center;
				font-size: 18px;
				padding-bottom: 20px;
			}
			.left>div{
				height: 50px;
				margin-bottom: 20px;
				line-height: 50px;
				background-color: orange;
				color: white;
				cursor: pointer;
			}
			/* .left>div:hover{
				background-color: blue;
			} */
			.box .active{
				background-color: blue;
			}
			.right>div{
				display: none;
				margin-top: 10px;
			}
			.right>.show{
				display: block;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="left">
				<div>1</div>
				<div>2</div>
				<div>3</div>
				<div>4</div>
			</div>
			<div class="right">
				<div class="show">
					<div>
						<h2>内容1</h2>
					</div>
					<div>
						<h2>内容2</h2>
					</div>
					<div>
						<h2>内容3</h2>
					</div>
					<div>
						<h2>内容4</h2>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		var divL=document.querySelectorAll(".left>div");
		var divR=document.querySelectorAll(".right>div>div");
		for(var i=0;i<divL.length;i++){
			divL[i].index=i;
			divL[i].onclick = function(){
				for(var i=0;i<divL.length;i++){
					divL[i].style.background=""
				}
				this.style.background="blue";
				for(n=0;n<divR.length;n++){
					divR[n].style.display = "none";
				}
				divR[this.index].style.display = "block"
			}
		}
	</script>
</html>
